<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var name = "iwen";

        var user = {
            //正常写法
            //name:name,

            //属性名和属性值是同样的变量名的时候可以使用简便写法
            name,

            // getName:function(){
            //     console.log(this.name);
            // }

            //简便写法
            getName(){
                console.log(this.name)
            }
        }
        console.log(user.name);
        user.getName();
        


        function getPoint(){
            var x = 10;
            var y = 20;
            //可以采用这种简便方法
            return{x, y}
        }

        console.log(getPoint().x, getPoint().y);


        //es6允许用表达式作为对象的属性
        let p = "name"
        var obj = {
            [p]:"iwen",
            age:10
        }
        console.log(obj);

        //对象的扩展运算符
        var n = {...user}
        console.log(n);
        
        


    </script>
</body>
</html>